package com.woniuxy;

import com.woniuxy.entity.Person;
import com.woniuxy.service.PersonService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

/**
 * @Author 罗蔚
 * @Date 2022/3/29 11:38
 * @Description TODO
 */
public class PersonTest {
    public static void main(String[] args) {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
        PersonService personService = applicationContext.getBean("personService", PersonService.class);
        //增加
//        int i = personService.addOne(new Person("张1",12));
//        if (i>0){
//            System.out.println("插入成功");
//        }

        //查找
//        List<Person> list = personService.findAll();
//        list.forEach(System.out::println);

        //删除
//        int i = personService.deleteOne(16);
//        if (i > 0) {
//            System.out.println("删除成功");
//        }

        //修改
        int i = personService.updataOne(new Person(16, "王五麻子", 10));
        if (i > 0) {
            System.out.println("修改成功");
        }
    }
}
